package offer;

public class offer04 {
}
class Solution4 {
    public  static boolean findNumberIn2DArray(int[][] matrix, int target) {
        if(matrix.length==0)
        {
            return false;
        }
        int i= 0;
        int j = matrix[0].length-1;
        boolean flag = false;
        while (i<matrix.length&&j>=0)
        {
            if(target == matrix[i][j])
            {
                flag = true;
                break;
            }
            if((i<matrix.length&&j>=0)&&target<matrix[i][j])
            {
                j--;
            }
            if((i<matrix.length&&j>=0)&&j>=0&&target>matrix[i][j])
            {
                i++;
            }
        }

        return flag;
    }

    public static void main(String[] args) {
        int[][] nums = {{-5}};
        boolean numberIn2DArray = findNumberIn2DArray(nums, -10);

    }
}